<template>
  <view class="template-hot tn-safe-area-inset-bottom">
    <!-- 顶部自定义导航 -->
    <tn-nav-bar fixed alpha customBack>
      <view slot="back" class='tn-custom-nav-bar__back'
        @click="goBack">
        <text class='icon tn-icon-left'></text>
        <text class='icon tn-icon-home-capsule-fill'></text>
      </view>
    </tn-nav-bar>
    
     
   <view class="tn-search-fixed">
     <view class="tn-flex tn-flex-row-between tn-flex-col-center tn-margin" :style="{marginTop: vuex_custom_bar_height + 'px'}">
	   <view class="justify-content-item tn-text-df tn-color-grey" @click="showModel">
	   		 <text class="tn-padding-xs">筛选</text>
	   		 <text class="tn-icon-filter"></text>
	   </view>
	   <view class="justify-content-item align-content-item">
         <view class="tn-bg-gray--light tn-flex tn-flex-col-center" style="border-radius: 100rpx;padding: 10rpx 20rpx 10rpx 20rpx;width: 100%;">
           <text class="tn-icon-search justify-content-item tn-padding-right-xs tn-color-gray tn-text-lg"></text>
           <input class="justify-content-item" placeholder="想搜点什么咧" name="input" placeholder-style="color:#AAAAAA" v-model="inputValue" @input="handleUserInput"></input>
         </view>
       </view>
       
       <view class="align-content-item">
         <view class="justify-content-item tn-text-center">
           <tn-button backgroundColor="#82B2FF" shape="round" padding="20rpx 20rpx" width="150rpx" shadow fontBold @click="search()">
             <text class="tn-color-white">搜 索</text>
           </tn-button>
         </view>
       </view>
     </view>
   </view>
   <scroll-view  @scrolltolower="loadMore" style="height: 1200rpx;" scroll-y="true">
   <view class="tn-info__container tn-flex tn-flex-wrap tn-flex-col-center tn-flex-row-between tn-margin-left tn-margin-right" >
     <block v-for="(item, index) in localReserve" :key="index">
       <view class="article-shadow tn-margin-sm" style="margin: 2px 0;" @click="tn('/circlePages/king?userId='+item.userId)">
         <view class="tn-flex">
           <!-- <view class="image-pic tn-margin-sm" :style="'background-image:url(' + item.url + ')'">
             <view class="image-article">
             </view>
           </view> -->
		   <view class="image-pic tn-margin-sm" v-if="item.url" :style="'background-image:url(' + item.url + ')'">  
		       <view class="image-article">  
		       </view>  
		   </view>  
		   <view class="image-pic tn-margin-sm" v-else style="background-image: url('https://img0.baidu.com/it/u=3508156229,3783674530&fm=253&app=138&size=w931&n=0&f=JPEG&fmt=auto?sec=1705510800&t=dbcfc6a2f6154e08ba89baf0d8ecf4a5')">  
		       <view class="image-article">  
		       </view>  
		   </view>
           <view class="tn-margin-sm tn-padding-top-xs" style="width: 100%;">
             <view class="tn-text-lg tn-text-bold clamp-text-1 tn-text-justify ">
               {{ item.name ? (item.name === 0 ? '保密' : item.name) : '保密' }} 
			   <text class='tn-icon-vip-text' v-if="item.ifVip !== 0"></text>  
			   <text class='purple-text-2' v-if="item.ifVip === 0"></text>
             </view>  
             <view class="tn-flex tn-flex-row-between tn-flex-col-between tn-padding-top-xs" style="min-height: 70rpx;">
               <view class="justify-content-item tn-flex tn-flex-col-center">
                 <text class="info">{{ item.age  }}岁  ·  {{ item.starSign ? (item.starSign === 0 ? '保密' : item.starSign) : '保密' }}  ·  {{ item.height ? (item.height === 0 ? '保密' : `${item.height}cm`) : '保密' }}  ·  {{ item.educationBackground ? (item.educationBackground === 0 ? '保密' : item.educationBackground) : '保密' }}  ·  {{ item.annualSalary ? (item.annualSalary === 0 ? '保密' : item.annualSalary) : '保密' }}</text>
               </view>
             </view>
             <view class="tn-flex tn-flex-row-between tn-flex-col-between">
              <view class="justify-content-item tn-flex tn-flex-col-center">
                <text class="info">{{ item.jobNature ? (item.jobNature === 0 ? ' ' : item.jobNature) : '保密' }}  ·  {{ item.marriageHistory ===1 ? '离异':'未婚'}}</text>
              </view>
             </view>
           </view>
         </view>
       </view>
     </block>
   </view>
   </scroll-view>
<tn-modal v-model="filterShow" :button="button" :custom="true" :showCloseBtn="true" width="100%" :maskCloseable="false" >
  <scroll-view class="custom-modal-content" style="height: 750rpx;" scroll-y="true">
    <view class="tn-icon tn-icon-about-fill"></view>
    <!-- <view class="text pt">性别：</view>
    <view class="text">
		<span  :class=" (filter.sex === '' && filter.sex !== 0) ? 'se-btn default' : 'se-btn'" @click="this.filter.sex=''">不限</span>
		<span :class=" filter.sex === 1 ? 'se-btn default' : 'se-btn'" @click="this.filter.sex=1">男</span>
		<span :class=" filter.sex === 0 ? 'se-btn default' : 'se-btn'" @click="this.filter.sex=0">女</span>
	</view> -->
	<view class="text pt">年龄（岁）：</view>
	<view class="text">
		 <input class="min-input" v-model="filter.minAge"  type="number"/> 到 <input v-model="filter.maxAge" class="min-input"  type="number"/> 岁
	</view>
    <view class="text pt">身高：</view>
	<view class="text">
		 <input class="min-input" v-model="filter.minHeight"  type="number"/> 到 <input v-model="filter.maxHeight"  class="min-input"  type="number"/> cm
	</view>
   
    <view class="text pt">学历：</view>
	<view class="text noflex">
		<span :class="filter.educationBackground == ''  ? 'se-btn default' : 'se-btn'" @click="this.filter.educationBackground=''" >不限</span>
		<span :class=" (filter.educationBackground == item.label) ? 'se-btn default' : 'se-btn'" v-for="(item,index) in education" @click="this.filter.educationBackground=item.label">{{item.label}}</span>
	</view>
   <!-- <view class="text pt">所在地：</view>
	<view class="text">
		<span :class="filter.address == ''  ? 'se-btn default' : 'se-btn'" @click="this.filter.address=''">不限</span>
		<span :class="filter.address !== ''  ? 'se-btn default' : 'se-btn'" @click="this.addressShow = true">{{filter.address ? filter.address : '选择地区'}}</span>
		<tn-picker v-model="addressShow" :params="addressParams" @confirm="choseAddress" mode="region" ></tn-picker>
	</view> -->
	<view class="text pt">婚史：</view>
	<view class="text">
		<span  :class=" (filter.marriageHistory === '' && filter.marriageHistory !== 0) ? 'se-btn default' : 'se-btn'" @click="this.filter.marriageHistory=''">不限</span>
		<span :class=" filter.marriageHistory === 1 ? 'se-btn default' : 'se-btn'" @click="this.filter.marriageHistory=1">离异</span>
		<span :class=" filter.marriageHistory === 0 ? 'se-btn default' : 'se-btn'" @click="this.filter.marriageHistory=0">未婚</span>
	</view>
	<!-- <view class="text pt">是否有子女：</view>
	<view class="text">
		<span  :class=" (filter.childSituation === '' && filter.childSituation !== 0) ? 'se-btn default' : 'se-btn'" @click="this.filter.childSituation=''">不限</span>
		<span :class=" filter.childSituation === 1 ? 'se-btn default' : 'se-btn'" @click="this.filter.childSituation=1">有子女</span>
		<span :class=" filter.childSituation === 0 ? 'se-btn default' : 'se-btn'" @click="this.filter.childSituation=0">无子女</span>
	</view> -->
	<view class="text pt">是否有房：</view>
	<view class="text">
		<span  :class=" (filter.houseSituation === '' && filter.houseSituation !== 0) ? 'se-btn default' : 'se-btn'" @click="this.filter.houseSituation=''">不限</span>
		<span :class=" filter.houseSituation === 1 ? 'se-btn default' : 'se-btn'" @click="this.filter.houseSituation=1">有房</span>
		<span :class=" filter.houseSituation === 0 ? 'se-btn default' : 'se-btn'" @click="this.filter.houseSituation=0">无房</span>
	</view>
	<view class="text pt">是否有车：</view>
	<view class="text">
		<span  :class=" (filter.carSituation === '' && filter.carSituation !== 0) ? 'se-btn default' : 'se-btn'" @click="this.filter.carSituation=''">不限</span>
		<span :class=" filter.carSituation === 1 ? 'se-btn default' : 'se-btn'" @click="this.filter.carSituation=1">有车</span>
		<span :class=" filter.carSituation === 0 ? 'se-btn default' : 'se-btn'" @click="this.filter.carSituation=0">无车</span>
	</view>
    <view class="text pt">年收入：</view>
	<view class="text noflex">
		<span :class="filter.annualSalary == ''  ? 'se-btn default' : 'se-btn'" @click="this.filter.annualSalary=''">不限</span>
		<span :class="filter.annualSalary == item.label  ? 'se-btn default' : 'se-btn'" v-for="(item,index) in annualSalary" @click="this.filter.annualSalary=item.label">{{item.label}}</span>
	</view>
	
	<view class="text bt">
		<tn-button @click="this.filterShow = false" backgroundColor="#e4da7e" fontColor="#080808" style="margin-right: 12px;">取消</tn-button>
		<tn-button backgroundColor="#01BEFF" @click="subFilter" fontColor="#080808">确定</tn-button>
	</view>
  </scroll-view>
</tn-modal>
    
  </view>
</template>

<script>
  import template_page_mixin from '@/libs/mixin/template_page_mixin.js'
  import $INFO from '@/common/infoMap.js';
  import request from "@/common/request.js"
  export default {
    name: 'People',
    mixins: [template_page_mixin],
    data(){
      return {
		addressShow:false,
		education:$INFO.education,
		annualSalary:$INFO.annualSalary,
		addressParams:{
		  province:true,
		  city:true,
		  area:true
		},
		filter:{
			// sex:'',
			minHeight:'',
			maxHeight:'',
			minWeight:'',
			maxWeight:'',
			minAge:'',
			maxAge:'',
			address:'',
			annualSalary:'',
			educationBackground:'',
			marriageHistory:'',
			childSituation:'',
			houseSituation:'',
			carSituation:'',
		},
		pageNum: 1,
		pageSize: 10,
		hasMoreData: true,
		filterShow:false,
        cardCur: 0,
		inputValue: '' ,
        reserve: [],
	   localReserve: [],
      }
    },
	 watch: {  
	    // 当 prop 更改时更新本地状态  
	    reserve(newVal) {  
	      this.localReserve = newVal;  
	    }  
	  },
	mounted() {
		// let _t = this;
		// uni.$on("peopel",function(){
		// 	// _t.pageNum=1
		// 	// _t.pageSize=10
		// 	_t.search()
		// })
		this.search()
	},
    methods: {
		turnLogin(){
			uni.removeStorageSync("token")
			uni.removeStorageSync("userInfo")
			uni.navigateTo({
				url: '/minePages/login',
			});
		},
		choseAddress(e){
			 this.filter.address = (e.province.label + e.city.label + e.area.label)
		},
		showModel(){
			this.filterShow = true
		},
      // cardSwiper
      cardSwiper(e) {
        this.cardCur = e.detail.current
      },
	  subFilter(){
		this.search();
		this.filterShow = false;
	  },
	  loadMore(){
		  // 当滚动到底部时加载更多数据
		if (this.hasMoreData == true) {
			this.pageNum++;
		    this.search(); // 调用你的搜索函数以获取更多数据
			
		}
	  },
      // 跳转
      tn(e) {
      	uni.navigateTo({
      		url: e,
      	});
      }, 
	      handleUserInput() {  
	        // 在这里获取用户输入的数据  
	        const userInput = this.inputValue;  
	        console.log(userInput);
			return userInput;
	      },     
	  search(){
		  //console.log('点击搜索');
		 // console.log(this.filter.annualSalary)
		 let name=this.handleUserInput()
		 
		 // console.log("################"+name)
		  const data ={
			annualSalary: this.filter.annualSalary,
			educationBackground: this.filter.educationBackground,
			maxAge: this.filter.maxAge,
			maxHeight: this.filter.maxHeight,
			maxWeight: this.filter.maxWeight,
			minAge: this.filter.minAge,
			minHeight: this.filter.minHeight,
			minWeight: this.filter.minWeight,
			// sex: this.filter.sex,
			name: name
		  }
		  request.post(`friend/wx/member/list?pageNum=${this.pageNum}&pageSize=${this.pageSize}`, data).then(res => {  
		    let _data = res[1]['data'];  
			console.log(_data)
		    const newData = res[1]['data'].rows;
			//console.log("????????????")
			//console.log(newData)
		    if (_data.code == 200) {  
		      // 检查是否还有更多数据可加载
			 // console.log(newData.length)
			  //pageNum*pageSize<total 
			  
			  // 如果不是分页
			  if(this.pageNum == 1){
				  this.reserve = newData;
			  }else{
				if ((this.pageNum-1)*this.pageSize<_data.total) {
				  this.reserve = [...this.reserve, ...newData]; 
				} else {
				  this.hasMoreData = false; // 没有更多数据可加载
				}
			  }
		                
		    } else if (_data.code == 401) {  
		   //    this.reserve = [{
				 //  age: 0,
				 //  annualSalary: null,
				 //  baseStr: "0岁 . 摩羯座 . 0cm . null . null",
				 //  birthday: "2024-01-04",
				 //  educationBackground: null,
				 //  haveChild: 0,
				 //  height: 0,
				 //  ifAuth: 0,
				 //  ifVip: 0,
				 //  inIndustry: null,
				 //  jobNature: null,
				 //  marriageHistory: 0,
				 //  name: "肉丝儿",
				 //  pictureNum: 1,
				 //  presentPlace: null,
				 //  selfIntroduction: null,
				 //  sex: 1,
				 //  starSign: "摩羯座",
				 //  url: "https://img0.baidu.com/it/u=1958088152,1515231113&fm=253&app=138&size=w931&n=0&f=JPEG&fmt=auto?sec=1704819600&t=5d23f3fff3a9f69f0618d614ed53caf0",
				 //  userId: "2",
				 //  weight: 0,
				 //  workStr: "null . null . 0"
			  // },
			  // {
				 //  age: 18,
				 //  annualSalary: "4万以内",
				 //  baseStr: "18岁 . 白羊座 . 187cm . 小学 . 4万以内",
				 //  birthday: "2006-01-12",
				 //  educationBackground: "小学",
				 //  haveChild: 0,
				 //  height: 187,
				 //  ifAuth: 0,
				 //  ifVip: 0,
				 //  inIndustry: "计算机",
				 //  jobNature: "私企员工",
				 //  marriageHistory: 0,
				 //  name: "紫色心情",
				 //  pictureNum: 2,
				 //  presentPlace: "北京市市辖区东城区",
				 //  selfIntroduction: "",
				 //  sex: 1,
				 //  starSign: "白羊座",
				 //  url: "https://img0.baidu.com/it/u=989499080,3347860717&fm=253&app=138&size=w931&n=0&f=JPEG&fmt=auto?sec=1713891600&t=2a2e7a2ac63afdcf0f5ea2470741179a",
				 //  userId: "3",
				 //  weight: 64,
				 //  workStr: "计算机 . 私企员工 . 0"
			  // },
			  // {
				 //  age: 0,
				 //  annualSalary: null,
				 //  baseStr: "0岁 . 射手座 . 0cm . 不限 . null",
				 //  birthday: "2024-01-04",
				 //  educationBackground: "不限",
				 //  haveChild: 0,
				 //  height: 0,
				 //  ifAuth: 0,
				 //  ifVip: 1,
				 //  inIndustry: null,
				 //  jobNature: null,
				 //  marriageHistory: 0,
				 //  name: "冰雪玫瑰",
				 //  pictureNum: 1,
				 //  presentPlace: null,
				 //  selfIntroduction: null,
				 //  sex: 1,
				 //  starSign: "射手座",
				 //  url: "https://img0.baidu.com/it/u=3360976321,1225938825&fm=253&app=138&size=w931&n=0&f=JPEG&fmt=auto?sec=1713891600&t=976c7444b90ca683d70fa344c235ec07",
				 //  userId: "13",
				 //  weight: 0,
				 //  workStr: "null . null . 0"
			  // }]  
		    }
			
		  });
    }
  }
  }

</script>

<style lang="scss" scoped>
  .template-plan{
  }
  /* 胶囊*/
  .tn-custom-nav-bar__back {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    justify-content: space-evenly;
    align-items: center;
    box-sizing: border-box;
    background-color: rgba(0, 0, 0, 0.15);
    border-radius: 1000rpx;
    border: 1rpx solid rgba(255, 255, 255, 0.5);
    color: #FFFFFF;
    font-size: 18px;
    
    .icon {
      display: block;
      flex: 1;
      margin: auto;
      text-align: center;
    }
    
    &:before {
      content: " ";
      width: 1rpx;
      height: 110%;
      position: absolute;
      top: 22.5%;
      left: 0;
      right: 0;
      margin: auto;
      transform: scale(0.5);
      transform-origin: 0 0;
      pointer-events: none;
      box-sizing: border-box;
      opacity: 0.7;
      background-color: #FFFFFF;
    }
  }
  
  /* 轮播 start*/
  .card-swiper {
    height: 570rpx !important;
  }
  
  .card-swiper swiper-item {
    width: 450rpx !important;
    left: 30rpx;
    box-sizing: border-box;
    padding: 0rpx 0rpx 80rpx 0rpx;
    overflow: initial;
  }
  
  .card-swiper swiper-item .swiper-item {
    width: 100%;
    display: block;
    height: 100%;
    border-radius: 10rpx;
    transform: scale(0.7) translate(0rpx,-104rpx);
    transition: all 0.3s ease-in 0s;
    will-change: transform;
    // overflow: hidden;
  }
  
  .card-swiper swiper-item.cur .swiper-item {
    transform: none;
    transition: all 0.3s ease-in 0s;
    will-change: transform;
  }
  
  .card-swiper swiper-item .swiper-item-text {
    margin-top: -100rpx;
    width: 100%;
    display: block;
    height: 50%;
    border-radius: 10rpx;
    transform: translate(20rpx, -30rpx) scale(0.7, 0.7);
    transition: all 0.4s ease 0s;
    will-change: transform;
    overflow: hidden;
    color: #000000;
    // background-image: linear-gradient(rgba(255, 255, 255, 0), rgba(0, 0, 0, 0));
    height: 140rpx;
  }
  
  .card-swiper swiper-item.cur .swiper-item-text {
    margin-top: -150rpx;
    padding-left: 30rpx;
    width: 500rpx !important;
    transform: translate(-25rpx, 20rpx) scale(0.9, 0.9);
    transition: all 0.4s ease 0s;
    will-change: transform;
    color: #FFFFFF;
    text-shadow: 0rpx 10rpx 20rpx rgba(0,0,0,0.1);
    // background-image: linear-gradient(rgba(255, 255, 255, 0.01), rgba(0, 0, 0, 0.4));
    height: 137rpx;
  }
  
  .image-banner{
    display: flex;
    align-items: center;
    justify-content: center;
    // border: 1rpx solid red;
  }
  .image-banner image{
    width: 100%;
    height: 100%;
  }
  /* 轮播指示点 start*/
  .indication{
    z-index: 9999;
    width: 100%;
    height: 36rpx;
    position: absolute;
    display:flex;
    flex-direction:row;
    align-items:center;
    justify-content:center;
  }
  
  .spot{
    background-color: #000;
    opacity: 0.4;
    width: 10rpx;
    height: 10rpx;
    border-radius: 20rpx;
    margin: 0 8rpx !important;
    right: -270rpx;
    top: -100rpx;
    position: relative;
  }
  
  .spot.active{
    opacity: 1;
    width: 10rpx;
    background-color: #000;
  }
  
  /* 计划内容 start*/
  .tn-plan-content {
    &__item {
      display: inline-block;
      line-height: 45rpx;
      padding: 10rpx 30rpx;
      margin: 20rpx 20rpx 5rpx 0rpx;
      
      &--prefix {
        padding-right: 10rpx;
      }  
    }
  }
  .tn-plan-content2 {
    &__item {
      line-height: 45rpx;
      padding: 15rpx 30rpx;
      margin: 30rpx 0rpx 10rpx 0rpx;
      
      &--prefix {
        padding-right: 10rpx;
      }  
    }
  }
  /* 计划内容 end*/
  
  /* 资讯主图 start*/
  .image-article {
    border-radius: 8rpx;
    // border: 1rpx solid #F8F7F8;
    width: 160rpx;
    height: 160rpx;
    position: relative;
  }
  
  .image-pic {
    background-size: cover;
    background-repeat: no-repeat;
    // background-attachment:fixed;
    background-position: top;
    border-radius: 10rpx;
  }
  
  .article-shadow {
    border-radius: 15rpx;
    //box-shadow: 0rpx 0rpx 50rpx 0rpx rgba(0, 0, 0, 0.07);
  }
  
  /* 文字截取*/
  .clamp-text-1 {
    -webkit-line-clamp: 1;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    text-overflow: ellipsis;
    overflow: hidden;
  }
  
  .clamp-text-2 {
    -webkit-line-clamp: 2;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    text-overflow: ellipsis;
    overflow: hidden;
  }
  
  /* 标签内容 start*/
  .tn-tag-content {
    &__item {
      display: inline-block;
      line-height: 35rpx;
      padding: 5rpx 25rpx;
  
      &--prefix {
        padding-right: 10rpx;
      }
    }
  }

  .min-input {
	  width: 60px;display: inline-block;
	  height: 26px!important;
	  margin: 0 6px;
	  padding: 0!important;
	  line-height: 26px;
	  text-align: center!important;
	  justify-content: center;
	  border: 1px solid #ccc;
  }
  .se-btn{
	  height: 23px;
	  line-height: 23px;
	  padding: 0;
	  text-align: center;
	  margin-right: 5px;
	  background: #f3f0f0;
	  min-width: 45px;
	  padding: 0 10px;
	  border-radius: 5px;
	  display: inline-block;
	  margin-bottom: 8px;
  }
  .se-btn.default{background: #efddc9!important}
  .pt{margin: 12px 0 4px 0;}
  .text{display: flex;
    align-items: center;}
	.text.noflex{display: inline-block;}
  .text.bt{text-align: center;padding: 18px 0;justify-content: center;}
  .custom-modal-content{height: 350px;overflow-y: scroll;}
  .tn-icon-vip-text {  
        color: purple; 
		font-size: 20px;
      }
	.purple-text-2 {
	    color: purple; 
	  	font-size: 8px;
	}
</style>
